import java.awt.Component;
import java.awt.Container;
import javax.swing.JApplet;
import javax.swing.JRootPane;

public class MyJApplet
extends JApplet
{
  private static final long serialVersionUID = 1L;

  /*****************************************************************\
   * Construction
  \*****************************************************************/
  public MyJApplet()
  {
    System.out.println("MyJApplet()");
    setName("MyJApplet");
  }

  @Override
  protected JRootPane createRootPane()
  {
    System.out.println("MyJFrame.createJRootPane()");
    return new MyJRootPane();
  }

  /*****************************************************************\
   * Lifecycle
  \*****************************************************************/
  @Override
  public void init()
  {
    System.out.println("MyJApplet.init()");
  }

  @Override
  public void start()
  {
    System.out.println("MyJApplet.start()");
    getGlassPane().setVisible(true);
  }

  @Override
  public void stop()
  {
    System.out.println("MyJApplet.stop()");
  }

  @Override
  public void destroy()
  {
    System.out.println("MyJApplet.destroy()");
  }

  /*****************************************************************\
   * Debug info
  \*****************************************************************/
  public void printInfo()
  {
    System.out.println("MyJApplet.printInfo()");
    printContainer(   "", this);
    printContainer(  " ", getRootPane());
    printContainer( "  ", getLayeredPane());
    printContainer("   ", getContentPane());
  }

  private void printContainer(String s, Container container)
  {
    if (container != null)
    {
      Component[] component = container.getComponents();
      for (int i=0; i<component.length; i++)
      {
        System.out.println(s+component[i]);
      }
    }
  }
}
